package com.ktjy.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktjy.mapper.StorageMapper;
import com.ktjy.pojo.Storage;
import com.ktjy.service.IStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jjx
 * @since 2025-01-16
 */
@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements IStorageService {
    @Autowired
    StorageMapper storageMapper;

    @Override
    public IPage<Storage> findPage(Storage storage, Integer pageNo, Integer pageSize) {
        //组装分页条件
        Page<Storage> page = new Page<>(pageNo, pageSize);

        //组装过滤条件 动态sql
        Map<String, Object> param = new HashMap<>();
        param.put("prodName", storage.getProdName());
        param.put("stkWarehouse", storage.getStkWarehouse());

        //调用分页方法
        IPage<Storage> storagePage = storageMapper.getByPage(page, param);

        //返回分页对象
        return storagePage;
    }
}